
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:u9mobile/models/area.dart';
import 'package:u9mobile/models/template.dart';

class AttachList extends StatefulWidget{
  const AttachList({super.key});

  @override
  State<AttachList> createState() => _AttachListState();
}

class _AttachListState extends State<AttachList> {
  String? selectedOption="选项1";
  Future<void> loadAsset() async {
    try {
      String area = await rootBundle.loadString('area.json');
      dynamic areaMap = json.decode(area);
      Template a=Template.fromJson(areaMap);
    } catch (e) {
      print('Error loading asset: $e');
    }
  }

  @override
  Widget build(BuildContext context){
    return Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              DropdownButton<String>(
                value: selectedOption,
                onChanged: (String? value) {
                  selectedOption=value;
                },
                items: <String>['选项1', '选项2', '选项3', '选项4']
                  .map<DropdownMenuItem<String>>((String value) {
                    return DropdownMenuItem<String>(
                      value: value,
                      child: Text(value),
                    );
                  }).toList(),
              ),
              const SizedBox(height: 20),
              Text('当前选择: $selectedOption'),
              ElevatedButton(
                style: ElevatedButton.styleFrom(
                  backgroundColor: Colors.blue, // 设置背景颜色
                  foregroundColor: Colors.white, // 设置文本颜色
                ),
                onPressed: () {
                  loadAsset();
                },
                child: const Text('审批'),
              ),
            ],
          ),
        );
  }
}